#ifndef VEHICLE_SYSTEM_H
#define VEHICLE_SYSTEM_H

#include <Arduino.h>
#include <ArduinoJson.h>
#include <string.h>
#include "control/motor_controller.h"
#include "sensor/sensor_manager.h"
#include "config_manager.h"

// 主车辆控制系统
class VehicleSystem {
private:
  MotorController* motorController;
  SensorManager* sensorManager;
  ConfigManager* configManager;
  char commandBuffer[32];
  byte bufferIndex;

public:
  VehicleSystem(MotorController* mc, SensorManager* sm, ConfigManager* cm) {
    motorController = mc;
    sensorManager = sm;
    configManager = cm;
    bufferIndex = 0;
  }

  void init();
  void processSerialCommands();
  void processCommand(char* cmd);
  void processConfig(char* config);
  void updateSensors();
  void checkSafety();
  void loop();
};

#endif // VEHICLE_SYSTEM_H